from selenium import webdriver
from time import sleep

from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

# driver.get("http://www.baidu.com")
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("你过来啊")
# driver.find_element(By.CSS_SELECTOR,".btn.self-btn.bg.s_btn.btn_h.btnhover").click()

driver.get("http://localhost:9527/#/login")


#最大化
# driver.maximize_window()
# sleep(1)
#
# #设置大小
# driver.set_window_size(500,500)
# sleep(1)
#
# #位置
# driver.set_window_position(500,600)
# sleep(1)
driver.maximize_window()



driver.find_element(By.NAME,"username").send_keys("maliu")
driver.find_element(By.NAME,"password").send_keys("NewWord@9715")
driver.find_element(By.NAME,"code").send_keys("lanfun")
# driver.find_element(By.CSS_SELECTOR,".el-button.el-button--primary.el-button--medium").click()
driver.find_element(By.CSS_SELECTOR,"#Home_Login > section > div > div.form > form > div > div.el-form-item.login_button.el-form-item--medium > div > div > button").click()
sleep(1)
driver.back()
sleep(2)

driver.forward()
current_url = driver.current_url
print("当前网址为：",current_url)
title = driver.title
print("title:",title)

size = driver.find_element(By.CSS_SELECTOR,".el-avatar.el-avatar--circle").size
print(size)
text = driver.find_element(By.CSS_SELECTOR,"a").text
print("第一个a标签文本",text)
href = driver.find_element(By.CSS_SELECTOR,"a").get_attribute("href")
print("第一个a标签文本",href)

driver.find_element(By.CLASS_NAME,"mycoures").click()
sleep(1)
is_selected = driver.find_element(By.CSS_SELECTOR,".el-checkbox__input").is_selected()
print("是否选中",is_selected)
driver.find_element(By.CSS_SELECTOR,"#courseContent > div:nth-child(1) > div:nth-child(1) > div > div > div:nth-child(1) > label > span > span").click()
sleep(1)
driver.close()
sleep(1)
driver.quit()


action = ActionChains(driver)
